<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.longtop.com/intelliweb" prefix="e"%>
<%@ page isELIgnored="false"%>
<html>
	<head>
		<title>考核方案-总界面-SJH</title>
	</head>
<e:View id="eView" designProperty="width: 1024; height: 768">

	<div id="Invisual Controls" style="min-height: 40px;">
	<!--考核方案是否包含定性指标  -->
		<e:Command id="Command_isHasDxindex" action="com.longtop.perform.khyg.web.ProjectManageAction" method="hasDxIndex">
			<e:Parameter name="projectId" value=""></e:Parameter>
			<e:Parameter name="hasDxIndex" value=""></e:Parameter>
		</e:Command>		
	</div>
	
<body style="overflow: hidden">
<e:Page id="ePage" action="" onAfterLoadPage="ePage_onAfterLoadPage()">
  		<table style="width: 100%;height: 100%" border="0" cellpadding="0" cellspacing="0">
    		<tr height="6%">
       			<td align="left" valign="top">
       				<e:RecordNavigator id="RecordNavigator" showNavigatorButton="false">
						<e:RecordButton id="Button_scheme" label='1-定制考核方案' onClick="Button_scheme_onClick()"></e:RecordButton>
						<e:RecordButton id="Button_score" label="2-评分标准" onClick="Button_score_onClick()"></e:RecordButton>
						<e:RecordButton id="Button_relation" label="3-考核对象管理" onClick="Button_relation_onClick()"></e:RecordButton>
						<e:RecordButton id="Button_task" label="4-任务管理" onClick="Button_task_onClick()"></e:RecordButton>
						<e:RecordButton id="Button_subject" label="5-主观评分" onClick="Button_subject_onClick()"></e:RecordButton>
						<e:RecordButton id="Button_countScore" label="6-计算成绩" onClick="Button_countScore_onClick()"></e:RecordButton>
						<e:RecordButton id="Button_issueScore" label="7-发布成绩" onClick="Button_issueScore_onClick()"></e:RecordButton>
						<e:RecordButton id="Button_queryScore" label="8-查询成绩" onClick="Button_queryScore_onClick()"></e:RecordButton>
					</e:RecordNavigator>
        		</td>
        	</tr>
        	 <tr height="94%">
        		<td align="center" valign="top">
        			<!-- 对应的第几步的功能页面 -->
        			<iframe src="" id="project_frame" name="project_frame" frameborder="0" width="100%" height="100%" Target="scheme_frame">
	           	 	</iframe>
	           	 	
	           	 	<e:Text id="Text_projectId" visible="false"></e:Text>
	           	 	<e:Text id="Text_projectName" visible="false"></e:Text>
	           	 	
        		</td>
        	</tr>
  		</table>
</e:Page>
</body>

<script language="Javascript">
	var projectId = '${param.projectId}';
	//init:
	function ePage_onAfterLoadPage(){
		$J("Text_projectId").setValue(projectId);
		Button_scheme_onClick();//首先进入定制方案页面。
	}
	//第一步：定制方案
	function Button_scheme_onClick(){
		var path = "jsp/perform/khyg/project/projectOne_scheme.jsp";
		path = getProjectIdPath(path); //获取参数
		project_frame.navigate(__CONTEXT_PATH + path);//定向到自定页面
		refreshBtnStyle('scheme');	//使button不可点击
	}
	//第二步：评分标准
	function Button_score_onClick() {
		if (!checkPermission('score')) {
			return;
		}
		var path = "jsp/perform/khyg/project/projectTwo_score.jsp";
		path = getProjectIdPath(path);
		project_frame.navigate(__CONTEXT_PATH + path);
		refreshBtnStyle('score');
	}
	//第三步：考核对象管理
	function Button_relation_onClick() {
		if (!checkPermission('relation')) {
			return;
		}
		var path = "jsp/perform/khyg/project/projectThree_relation.jsp";
		path = getProjectIdPath(path);
		project_frame.navigate(__CONTEXT_PATH + path);
		refreshBtnStyle('relation');
	}
	//第四步：任务管理
	function Button_task_onClick (){
		if (!checkPermission('task')) {
			return;
		}
		var path = "jsp/perform/khyg/project/projectFour_task.jsp";
		path = getProjectIdPath(path);
		project_frame.navigate(__CONTEXT_PATH + path);
		refreshBtnStyle('task');	
	}
	//第五步：主观评分
	function Button_subject_onClick (){
		if (!checkPermission('subject')) {
			return;
		}
		var path = "jsp/perform/khyg/project/projectFive_subject.jsp";
		path = getProjectIdPath(path);
		project_frame.navigate(__CONTEXT_PATH + path);
		refreshBtnStyle('subject');	
	}	
	//第六步：计算成绩
	function Button_countScore_onClick (){
		if (!checkPermission('countScore')) {
			return;
		}
		var path = "jsp/perform/khyg/project/projectSix_countScore.jsp";
		path = getProjectIdPath(path);
		project_frame.navigate(__CONTEXT_PATH + path);
		refreshBtnStyle('countScore');	
	}	
	
	//第七步： 发布成绩
	function Button_issueScore_onClick (){
		if (!checkPermission('issueScore')) {
			return;
		}
		var path = "jsp/perform/khyg/project/projectSeven_issueScore.jsp";
		path = getProjectIdPath(path);
		project_frame.navigate(__CONTEXT_PATH + path);
		refreshBtnStyle('issueScore');	
	}
	
	//获取projectId，URL参数
	function getProjectIdPath(path) {
		var projectId = $J("Text_projectId").getValue();
		if (projectId !=null || projectId !="") {
			path = path + "?projectId=" + projectId;
		}
		return path;
	}
	
	//检查考核方案是否已经保存
	function isSchemeSave() {
		var projectId = $J("Text_projectId").getValue();
		if( projectId == "" || projectId == null ){
			return false;
		}else{
			return true;
		}
	}
	//button权限判断
	function checkPermission(btnType) {
		if (!isSchemeSave()) {
			MsgBox.showErrorMsg("请先保存考核方案！");	//没保存方案不能下一步
			return false;
		}		
		//判断方案是否存在定性考核指标
		if (btnType == "subject") {
			var projectId = $J("Text_projectId").getValue();
			Command_isHasDxindex.parameters.setValue("projectId",projectId);
			Command_isHasDxindex.execute();
			var hasDxIndex = Command_isHasDxindex.parameters.getValue("hasDxIndex");
			if (hasDxIndex == "false"){  
        		MsgBox.showWarnMsg("该考核方案不存在定性考核指标。");
				return false;
    		}
		}	
		return true;			
	}

	//更改button状态
	function refreshBtnStyle(btnType) {
		setBtnEnabled(true);
		var button = $J("RecordNavigator").getRecordButtonById("Button_"+btnType);
		button.setEnabled(false);
	}
	function setBtnEnabled(enabled) {
		$J("RecordNavigator").getRecordButtonById("Button_scheme").setEnabled(enabled);
		$J("RecordNavigator").getRecordButtonById("Button_score").setEnabled(enabled);
		$J("RecordNavigator").getRecordButtonById("Button_relation").setEnabled(enabled);
		$J("RecordNavigator").getRecordButtonById("Button_task").setEnabled(enabled);
		$J("RecordNavigator").getRecordButtonById("Button_subject").setEnabled(enabled);
		$J("RecordNavigator").getRecordButtonById("Button_countScore").setEnabled(enabled);
		$J("RecordNavigator").getRecordButtonById("Button_issueScore").setEnabled(enabled);
		$J("RecordNavigator").getRecordButtonById("Button_queryScore").setEnabled(enabled);
	}
</script>

</e:View>
</html>